<?php
defined('YII_ENV') or exit('Access Denied');

$urlManager = Yii::$app->urlManager;
$this->title = '团长基础配置';
?>
<link href="<?= Yii::$app->request->baseUrl ?>/statics/js/select2/select2.css" rel="stylesheet">
<link href="<?= Yii::$app->request->baseUrl ?>/statics/js/select2/select2-bootstrap.css" rel="stylesheet">
<div class="panel mb-3">
    <div class="panel-header"><?= $this->title ?></div>
    <div class="panel-body">
        <form class="form auto-form" method="post" autocomplete="off" return="<?= $urlManager->createUrl(['mch/purchase/default/setting']) ?>">
			
			<div class="form-group row">
                <div class="form-group-label col-3 text-right">
                    <label class="col-form-label required">绑定分类</label>
                </div>
                <div class="col-sm-5">
                    <select name="cat_id" class="form-control select2">
						<?php foreach( $cat_list as $k => $v ) : ?>
						<option value="<?php echo $v['id']; ?>" <?php if( $v['id'] == $setting->cat_id ): ?>selected<?php endif; ?>><?php echo $v['name']; ?></option>
						<?php endforeach; ?>
					</select>
                </div>
            </div>
			
			<div class="form-group row">
                <div class="form-group-label col-3 text-right">
                    <label class="col-form-label required">利润提成比例</label>
                </div>
                <div class="col-sm-5">
                    <input class="form-control" type="number" name="num" value="<?= $setting->num ?>"/>
                </div>
            </div>


            <div class="form-group row">
                <div class="form-group-label col-3 text-right">
                    <label class="col-form-label required">规则说明</label>
                </div>
                <div class="col-sm-5">
                    <textarea class="form-control" rows="15" name="rule"><?= $setting->rule ?></textarea>
                </div>
            </div>
			
            <div class="form-group row">
                <div class="form-group-label col-3 text-right"></div>
                <div class="col-9">
                    <a class="btn btn-primary auto-form-btn" href="javascript:">保存</a>
                </div>
            </div>
        </form>
    </div>
</div>
<script src="<?= Yii::$app->request->baseUrl ?>/statics/js/select2/select2.min.js"></script>
<script>
	if ($('.select2').length > 0) {
		$('.select2').each(function() {
			$(this).select2({})
		})
	}
</script>